package model;

import java.util.Set;


/**
 * This interface must be implemented by all classes
 * that modelises a Directed Graph Road. 
 * 
 * @author Thierry
 *
 */
public interface ISPRoad {

	/**
	 * 
	 * @return the departure vertex
	 */
	IVertex getDepartureVertex();
	
	/**
	 * 
	 * @return the arrival vertex
	 */
	IVertex getArrivalVertex();
	
	/**
	 * 
	 * @return vertexes in the road
	 */
	Set<IVertex> getVertexes();
	
	/**
	 * Changes the current vertex to the next vertex
	 * and returns the new current vertex if it exists, 
	 * null otherwise.
	 * 
	 * @return the new current vertex
	 */
	IVertex next();
	
	/**
	 * Returns the next vertex in the road
	 * without changing the current vertex,
	 * if it exists, null otherwise.
	 * 
	 * @return the next vertex
	 */
	IVertex getNextVertex();

	/**
	 * Indicates if road is empty
	 * 
	 * @return true if the road is empty, false
	 * otherwise.
	 */
	boolean isEmpty();
	
	/**
	 * Return the number of the
	 * vertexes in the road
	 * 
	 * @return the number of the vertexes 
	 * in the road
	 */
	int getLength();
	
	/**
	 * Returns the label of the next edge
	 * leaving from the current vertex.
	 * 
	 * @return the label of the next edge.
	 */
	String getNextLabel();
	
	/**
	 * Computes the sub-road extracted 
	 * between startIndex and endIndex 
	 * and returns it.
	 * 
	 * @param startIndex index of the first vertex
	 * @param endIndex index of the last index
	 * @return the sub-road.
	 */
	ISPRoad getSubRoad(int startIndex, int endIndex);
	
	/**
	 * Computes the label of the last 
	 * edge of the road and returns it
	 * 
	 * @return the label of the last 
	 * edge
	 */
	String getLastEdgeLabel();
	
	/**
	 * Sets the current vertex at the departure vertex
	 */
	void backToBeginning();
	
	/**
	 * Adds an edge to the road at the end of the current road. When the edge 
	 * is added the resulting object stills a Road. 
	 * That means that this object has only one departure vertex
	 * and only one arrival vertex. All vertexes between
	 * the departure vertex and the arrival vertex have just one successor 
	 * but can have several predecessors. 
	 * 
	 * @param departureVertex the departure vertex of the edge
	 * @param label the label of the edge
	 * @param arrivalVertex the arrival vertex of the edge
	 * @return true if the edge was added to the road. False otherwise.
	 */
	boolean addRoadEdge(IVertex departureVertex, String label, IVertex arrivalVertex);
	
	/**
	 * Removes the last added edge.
	 * 
	 * @return true if the edge was removed to the road, false otherwise.
	 */
	boolean removeLastEdge();
	
	SPRoad copy(SPRoad r);
}
